<?php
namespace control;
/*
*我的考勤类
*/

class workSignClass extends adIndexClass
{
    private const title = '我的考勤';
    private const page = 'workSign';
    private const table = 'work_sign';

    /*行政人事-考勤记录-查询条件*/
    public function home()
    {
        $html = text(array("name" => "month","laydate" => array("type" => "month"),"title" => L('person.table.yue_fen'),"value" => date("Y-m")));
        //返回
        return $this->homeFun($this->search($html));
    }
    /*行政人事-考勤记录-查询结果*/
    public function homeSearch($source='')
    {
        $month = $this->post('month') ? $this->post('month') : date("Y-m");
        if ($this->power("workSign", "seeAll") and !empty($this->post('stid'))) {
            $staff = query("staff", " stid = '".$this->post('stid')."' ");
            if (empty($staff['stid'])) {
                $json['html'] = L('person.table.wzdcyg');
            }
        } elseif(!empty($this->post('targetId'))){
            $staff = query("staff", " stid = '".$this->post('targetId')."' ");
        }else {
            $staff = $this->control;
        }
        if (empty($json['html'])) {
            $obj = new workSignCheckClass();
            $staffEntryRecord = query('staff_entry_record',"talentId = '$staff[talentId]' and state = '已通过' order by entryDate desc,time desc");
            $staff['entryDay'] = $staffEntryRecord['entryDate'];
            $json['html'] = $obj->table(["month" => $month, "staff" => $staff,'source'=>$source?:'personal']);
        }
        //返回
        return json_encode($json, 320);
    }

    public function clockRecord(){
        $html =
            hidden(array("name" => "targetId", "value" => $this->get('id'))) .
            text(array("name" => "month","laydate" => array("type" => "month"),"title" => L('person.table.yue_fen'),"value" => date("Y-m")));
        //返回
        $json['html'] = $this->search($html);
        return json_encode($json, 320);
    }
    public function clockRecordSearch(){
        return $this->homeSearch('other');
    }

}
